package com.wy.tcp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TcpService implements ApplicationRunner {
    @Autowired
    private ProxyDefinitionConfig proxyDefinitionConfig;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        doTcpTransfer();
    }

    private void doTcpTransfer() {
        List<ProxyParaModel> definitions = proxyDefinitionConfig.getDefinitions();
        for (ProxyParaModel definition : definitions) {
            new TcpProxyServer(definition).start();
        }
    }
}
